package cn.com.nes.site.controller.system;

import cn.com.nes.site.controller.system.vo.CallCenterApplyCheckVO;
import cn.com.nes.site.controller.system.vo.CallCenterApplyPageVO;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.service.system.callCenter.CallCenterService;
import cn.com.nes.site.service.system.callCenter.bo.CallCenterApplyCheckBO;
import cn.com.nes.site.service.system.callCenter.dto.CompanyApplyPageDto;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 客服中心接口
 */
@Slf4j
@Controller
@RequestMapping("/v2/system/callcenter")
public class CallCenterController {

    @Resource
    CallCenterService callCenterService;

    /**
     * 客服中心申请分页列表
     * @param vo
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getCallCenterApplyPage", method = RequestMethod.GET)
    @ResponseBody
    public PageData getCallCenterApplyPage(CallCenterApplyPageVO vo) throws Exception {
        Page<CompanyApplyPageDto>  page = callCenterService.getCallCenterApplyPage(vo.convertToBo());
        return PageData.ok(page, page.getRecords());
    }

    /**
     * 客服中心申请审核
     * @param vo
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/callCenterApplyCheck", method = RequestMethod.POST)
    @ResponseBody
    public PageData callCenterApplyCheck(@RequestBody @Validated CallCenterApplyCheckVO vo) throws Exception {
        callCenterService.callCenterApplyCheck(vo.convertToBo(new CallCenterApplyCheckBO()));
        return PageData.ok();
    }

}
